<script type="text/javascript" src="<?=base_url();?>java_scripts/vote_scripts.js"></script>

<link type="text/css" rel="stylesheet" href="<?=base_url()?>css/vote.css" />
<script type="text/javascript">
	function sortMe(event_id,sort_value){
		window.location="<?=site_url("vote/voteDetail")?>"+"/"+event_id+"/"+sort_value;
	}
	function search_vote(url_string){
		document.forms[0].action=url_string;
		return document.forms[0].submit();
		
	}
</script>
<?php 
	$myEvents=$events->result_array();
	$count=count($myEvents);
	$resultText="Search Results (".$count.")";
	$title=(!isset($sel_cat_id))? $Z_TRANS->value('title_vote_list') :$resultText;
?>

<div id="border">
<form name="" method="post" action="<?=site_url("vote/getSearch")?>">   
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
     <tr>
     <td valign="top">       
        <table width="705" border="0" align="center" id="usertitle">
          <tr>
            <td><h3><b><?=$title?><b></b></h3></td>
            <td align="right">
            		
            </td>
          </tr>
        </table>
        <div id="content">
        <div class="user_line_border_top" style="height:30px; padding-top:10px; padding-right:6px;  text-align:right">
        	<input name="txtkeyword" type="text" id="txtkeyword" style="width: 160px">&nbsp;
            <select name="selcat" id="selcat" >
                  <option value="0">All Categories</option>
                  <?php 
                      foreach ($categories->result_array() as $category) {
                          if(isset($sel_cat_id)){
                              $selectMe=($sel_cat_id==$category['vote_item_cat_id'])?"selected":"";
                          }else{
                              $selectMe=($category['vote_item_cat_id']==$topic['vote_item_cat_id'])?"selected":"";
                          }
                  ?>
                  <option <?=$selectMe?> value="<?=$category['vote_item_cat_id']?>"><?=$category['vote_item_cat_desc']?></option>
                  <?php 
                      }
                  ?>
            </select>
     		&nbsp;<a href="<?=site_url("vote/advanced")?>"><?=$Z_TRANS->value('title_advanced_search')?></a>&nbsp;&nbsp;<input type="submit" class="kh_button" value="<?=$Z_TRANS->value('btn_search')?>" style="background:#BD2031; width:66px; height:24px; color:#fff; border:0;-webkit-border-radius: 3px;-moz-border-radius: 3px;border-radius: 3px; cursor:pointer;" />
        </div>
        <div style="margin:10px auto;"></div>
                
        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="left_ttb_border">
    	<?php 
    	foreach ($events->result_array() as $event)
    	{
    		date_default_timezone_set("UTC");
    		$today_date = date("Y-m-d");
    		$status=($event['end_date']>=$today_date)?"Closed on": $Z_TRANS->value('title_completed');
    		//$fcolor=$status=($event['end_date']>=$today_date)?"red":"";
    		$enddate=date_postgres_to_html($event['end_date']);
    	?>
        <tr>
          <td width="85%" valign="center" height="30">&nbsp;&nbsp;<b><a class="vote_topic" style="color: blue;" href="<?=site_url("vote/voteDetail/".$event['event_id'])?>"><?=htmlspecialchars($event['top_name'])?></a></b><p align="justify" style="padding-left: 15px;  font-size: 12px;"><?=nl2br(htmlspecialchars($event['top_desc']))?></p></td>
          <td width="15%" align="center" valign="middle" style="padding-right: 5px;"><font color="red" style="font-size: 11px;"><?=$status?></font><br><b><?=$enddate?></b></td>
        </tr>
        <tr><td colspan="2">&nbsp;</td></tr>
        <?php 
        	}
        ?>
  		</table> <br />       


        </div>
        </td>
        <td width="254" valign="top">
			<?php include APPPATH."views/templates/common/right_content.php"; ?>
         </td>
         
      </tr>
  </table>
  </form>
</div>
